{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/bootstrap-editable.css">
{/block}
{block name="body"}
<div class="main-box clearfix">
    <header class="main-box-header clearfix">
        <div class="pull-left">
            <h2>{present name="data"}[ {$data['title']} ] 子{/present}菜单管理</h2>
        </div>
        <div class="pull-right">
            <!-- <div class="search-form pull-left">
                <div class="form-group">
                    <input type="text" name="title" class="form-control" value="{:input('title')}"
                           placeholder="请输入菜单名称">
                    <span class="input-group-btn"><a class="btn btn-default" href="javascript:;" id="search" url="__SELF__"><i class="icon-search"></i></a></span>
                </div>
            </div> -->
            <a class="btn btn-primary" href="{:url('add',array('pid'=>input('get.pid',0)))}">新 增</a>
            <button class="btn btn-danger ajax-post confirm" url="{:url('del')}" target-form="ids">删 除</button>
            <a class="btn btn-success" href="{:url('import',array('pid'=>input('get.pid',0)))}">导 入</a>
        </div>
    </header>
    <div class="main-box-body clearfix">
        <form class="ids">
            <div class="table-responsive clearfix">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th class="row-selected">
                                <input class="checkbox check-all" type="checkbox">
                            </th>
                            <th>ID</th>
                            <th>名称</th>
                            <th>上级菜单</th>
                            <th>分组</th>
                            <th>URL</th>
                            <th>排序</th>
                            <th>仅开发者模式显示</th>
                            <th>隐藏</th>
                            <th>操作</th>
                        </tr>
                    </thead>

                    <tbody>
                    {notempty name="list"}
                        {volist name="list" id="menu"}
                            <tr>
                                <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$menu.id}"></td>
                                <td>{$menu.id}</td>
                                <td>
                                    {$menu['level_show']}
                                    <a href="#" class="editable editable-click" data-id="{$menu['id']}" data-name="title" data-type="text" data-pk="{$menu['id']}" data-url="{:url('editable')}">{$menu['title']}</a>
                                    <a class="add-sub-cate" title="添加子分类" href="{:url('add?pid='.$menu['id'])}">
                                        <i class="fa fa-plus-square"></i>
                                    </a>
                                </td>
                                <td>{$menu.up_title|default='无'}</td>
                                <td>{$menu.group}</td>
                                <td>{$menu.url}</td>
                                <td><a href="#" class="editable editable-click" data-id="{$menu['id']}" data-name="sort" data-type="text" data-pk="{$menu['id']}" data-url="{:url('editable')}">{$menu['sort']}</a></td>
                                <td>
                                    <a href="{:url('toogleDev',array('id'=>$menu['id'],'value'=>abs($menu['is_dev']-1)))}"
                                       class="ajax-get">
                                        {$menu.is_dev_text}
                                    </a>
                                </td>
                                <td>
                                    <a href="{:url('toogleHide',array('id'=>$menu['id'],'value'=>abs($menu['hide']-1)))}"
                                       class="ajax-get">
                                        {$menu.hide_text}
                                    </a>
                                </td>
                                <td>
                                    <a title="编辑" href="{:url('edit?id='.$menu['id'])}">编辑</a>
                                    <a class="confirm ajax-get" title="删除" href="{:url('del?id='.$menu['id'])}">删除</a>
                                </td>
                            </tr>
                        {/volist}
                    {else/}
                        <td colspan="10" class="text-center"> aOh! 暂时还没有内容!</td>
                    {/notempty}
                    </tbody>
                </table>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-editable.min.js"></script>
<script type="text/javascript">
$(function () {
    $.fn.editable.defaults.mode = 'popup';
    $.fn.editableform.buttons = '<button type="submit" class="btn btn-success editable-submit btn-mini"><i class="fa fa-check-square-o fa-white"></i></button>' +
    '<button type="button" class="btn editable-cancel btn-mini"><i class="fa fa-times"></i></button>';
    $('.editable').editable();
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
});
</script>
{/block}